﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using CourseUtils;

namespace Fibonacci
{
    class Program
    {
        static void printFibonacciLoop(int num)
        {
            System.Diagnostics.Stopwatch swatch = new System.Diagnostics.Stopwatch();
            swatch.Start();

            ulong n = 0;
            int i = 0;
            ulong n1 = 0;
            ulong n2 = 1;
            
            for (i = 1; i < num; i++)
            {
                n = n1 + n2;
                n2 = n1;
                n1 = n;
                Console.Write("{0} ",n);
                
            }
            swatch.Stop();
            Console.WriteLine();
            Console.WriteLine(swatch.Elapsed);

                
        }
        static int fibonacci (int n) // не работает
        {
            int i = 0;
            if (n == 1 || n == 2)
            {
                i = 1;
                Console.Write("{0} ", i);
                return i;
                
            }
            return 
                i = (fibonacci(n - 1) + fibonacci(n - 2));
                Console.Write("{0} ", i);
                return i;
        }
        static void printFibonaccirecursion() // не работает
        {
            System.Diagnostics.Stopwatch swatch = new System.Diagnostics.Stopwatch();
            swatch.Start();



            swatch.Stop();
            Console.WriteLine();
            Console.WriteLine(swatch.Elapsed);
        }
        static void Main(string[] args)
        {
            int num = IOHelpers.ReadIntFromConsole("введите количество выводимых чисел");
            printFibonacciLoop(num);
            Console.ReadKey();
        }
    }
}
